<%@page import="java.util.ArrayList,karaoke.modelo.Comprobante"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
        <title>Sistema Karaoke</title>
        <link href="css/bootstrap-3.2.0.css" rel="stylesheet"/>
        <script src="js/jquery-1.10.2.js" type="text/javascript"></script>
        <script src="js/bootstrap-3.2.0.js" type="text/javascript"></script>
    </head>
    <body>
        <div class="container-fluid">
            <div class="col-md-8 col-md-offset-2">
                <div class="panel panel-default">
                    <div class="panel-heading">
                        <h4>Buscar Comprobante</h4>
                    </div>
                    <div style="float: right; margin: 20px">
                        <form method="post" action="<%= request.getContextPath()%>/ComprobanteNuevoServlet" 
                              class="form-inline" role="form">
                            <div class="form-group">
                                <input id="btnBuscar" class="form-control" type="submit" value="Genrar comprobante" />
                            </div>
                        </form>
                    </div>
                  
                    <div id="filtros" class="panel-body">
                        <form method="post" action="<%= request.getContextPath()%>/ComprobanteBuscarServlet"
                              class="form-inline" role="form">
                            <div class="form-group">
                                <input id="txtCodigo" name="txtBusqueda" class="form-control" 
                                       type="text" placeholder="Codigo" value=""/>
                                <input id="btnBuscar" class="form-control" type="submit" />
                            </div>
                        </form>
                    </div>
                    <div class="panel-body">
                        <table class="table table-hover">
                            <thead>
                                <tr>
                                    <th>
                                        Codigo
                                    </th>
                                    <th>
                                        Fecha
                                    </th>
                                    <th>
                                        Cliente
                                    </th>
                                    <th>
                                        Ruc
                                    </th>
                                    <th>
                                        Importe
                                    </th>
                                    <th>
                                        Igv
                                    </th>
                                    <th>
                                        Total
                                    </th>
                                    <th>
                                        Reserva
                                    </th>
                                    <th style="text-align: center">
                                        Eliminar
                                    </th>
                                </tr>
                            </thead>

                            <tbody>
                                <%
                                    ArrayList<Comprobante> comprobantes = (ArrayList<Comprobante>) request.getAttribute("COMPROBANTES");

                                    if (comprobantes != null) {
                                        for (Comprobante comprobante : comprobantes) {
                                            out.println("<tr>");
                                            out.println("<td>" + comprobante.getCodigo() + "</td>");
                                            out.println("<td>" + comprobante.getFechaFormato() + "</td>");
                                            out.println("<td>" + comprobante.getNombreCliente() + "</td>");
                                            out.println("<td>" + comprobante.getRuc() + "</td>");
                                            out.println("<td>" + comprobante.getImporte() + "</td>");
                                            out.println("<td>" + comprobante.getIgv() + "</td>");
                                            out.println("<td>" + comprobante.getTotal() + "</td>");
                                            out.println("<td>" + comprobante.getCodReserva() + "</td>");
                                            out.println("<td><form method='post' action='");
                                            out.println(request.getContextPath()+"/ComprobanteEliminarServlet?id="+comprobante.getIdComprobante() + "'>");
                                            out.println("<input value='Eliminar' class='form-control' type='submit'/>");
                                            out.println("</form></td>");
                                            out.println("</tr>");
                                        }
                                    }
                                %>

                                          
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </body>
</html>